home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13299 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: solon.com!not-for-mail
  2. From: rreed@unconfigured.xvnews.domain (Randy Reed)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Date: 6 Apr 1996 09:02:15 -0600
  6. Organization: The unconfigured xvnews people
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4k611n$amg@solutions.solon.com>
  10. References: <4jv7dk$d1k@solutions.solon.com>
  11. Reply-To: rreed@unconfigured.xvnews.domain
  12. NNTP-Posting-Host: solutions.solon.com
  13.  
  14.  
  15. In article <4jv7dk$d1k@solutions.solon.com>, schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz) writes:
  16.  >In article <4jttlq$3p1@solutions.solon.com>, nsmart@indigo.ie (Niall Smart) writes:
  17.  >
  18.  >|> I would prefer:
  19.  >|> 
  20.  >|> >for ( ; p<end_p; p++) 
  21.  >|> >    ++(*p);
  22.  >|> 
  23.  >|> or either of:
  24.  >|> 
  25.  >|> while (p < end_p)
  26.  >|> {
  27.  >|>     (*p)++;
  28.  >|>     p++;
  29.  >|> }
  30.  >|> 
  31.  >|> while (p++ < end_p)
  32.  >|> {
  33.  >|>     (*p)++;
  34.  >|> }
  35.  >|> 
  36.  >|> Zero chance for ambiguity in the last three versions.
  37.  >
  38.  >The third version is not equivalent to the other two.
  39.  >The second version uses up more than twice the screen space of the original.
  40.  >
  41.  >Konrad Schwarz
  42.  
  43.  
  44. Well Mr. Schwarz, IMHO it is not a matter of taste, but one of priorities. 
  45. Your priority seems to be screen space.  Since I can stretch my window 
  46. vertically, and I have more disk storage than I could code in a lifetime, 
  47. my priorities are:
  48. 1. Code Clarity
  49. 2. Speed of execution
  50. 3. Memory Usage
  51. I realize that I am a minority (probably more so on this newsgroup) but 
  52. if your code sample was delivered to me in a code walkthrough, I would
  53. reject it because I wouldn't want members of my team to code in that 
  54. fashion. 
  55.  
  56. It appears as if the original discussion was arrays .vs. pointers, and 
  57. to be honest, I prefer arrays for clarity, but would accept either, so 
  58. long as the code is clear-clear-clear.  Arrays are easier to monitor if
  59. you are using a debugger, since the array index variable is easier to 
  60. visualize than an offset from the original address. 
  61.  
  62. Just an opinion, but it's the only one I got. 
  63.  
  64. Randy Reed
  65.